package com.atguigu.gulimall.product.service.impl;

import com.atguigu.gulimall.product.entity.MusersEntity;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;

import com.atguigu.gulimall.product.dao.McollectDao;
import com.atguigu.gulimall.product.entity.McollectEntity;
import com.atguigu.gulimall.product.service.McollectService;
import org.springframework.util.StringUtils;


@Service("mcollectService")
public class McollectServiceImpl extends ServiceImpl<McollectDao, McollectEntity> implements McollectService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        String key = (String) params.get("key");
        QueryWrapper<McollectEntity> mcollectEntityQueryWrapper = new QueryWrapper<McollectEntity>();
        if(!StringUtils.isEmpty(key)){
            mcollectEntityQueryWrapper.eq("user_id",key).or().like("userName",key);
        }
        IPage<McollectEntity> page = this.page(
                new Query<McollectEntity>().getPage(params),mcollectEntityQueryWrapper

        );


        return new PageUtils(page);
    }

}